import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_boost/flutter_boost.dart';

class MainPage extends StatefulWidget {
  final String? data;
  const MainPage({Key? key, this.data}): super(key: key);

  @override
  State<MainPage> createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {

  @override
  void initState() {
    super.initState();
    print("进入到 Flutter 的商品列表页面");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(
          onPressed: () {
            BoostNavigator.instance.pop();
          },
          icon: Icon(Icons.arrow_back_ios_new),
        ),
        title: const Text("主页面 - Flutter页面"),
      ),
      body: Container(
        color: Colors.grey.withOpacity(0.1),
        width: double.infinity,
        height: double.infinity,
        child: Center(
          child: InkWell(
            child: Text(widget.data ?? ""),
            onTap: () {
              // Map<String, dynamic>? arguments = new Map<String, dynamic>();
              // arguments['content'] = '这是从Flutter主页面传过来的数据';
              // BoostNavigator.instance.push(
              //     "about",
              //     arguments: arguments
              // );
            },
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton.extended(
        label: Text(
          "跳转到原生页面",
          style: TextStyle(
              color: Colors.black
          ),
        ),
        backgroundColor: Colors.white,
        onPressed: () {
          Map<String, dynamic>? arguments = new Map<String, dynamic>();
          arguments['content'] = '这是从Flutter主页面传过来的数据';
          BoostNavigator.instance.push(
              "about",
              arguments: arguments
          );
        },
      ),
    );
  }

}